<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<script type="text/javascript" src="../Public/js/jq.js"></script>
<link rel="stylesheet" type="text/css" href="../Public/css/common.css" />
<script>
function add(id)
{
	$.post('__URL__/add_sch_spe',{
		'specialityid':id,
		'schoolid':'<?php echo $_GET["schoolid"];?>'
	},function(){
		window.location.reload();
	})	
}
function del(id)
{
	$.post('__URL__/del_sch_spe',{
		'id':id	
		},function(){
		window.location.reload();
	})	
}
function edit(id)
{
window.open('__URL__/edit_sch_spe/id/'+id);
}

function checkall()
{
	$('.ctl').attr('checked','checked');
}
function addall()
{
	result = '';
	$('.ctl').each(function(i)
	{
		if($(this).attr('checked') == true)
		{
			if(result == '')
			{
				result = $(this).val();
			}else
			{
				result += ','+$(this).val();
			}
		}
	})
	
	$.post('__URL__/add_sch_spe',{
		'specialityid':result,
		'schoolid':'<?php echo $_GET["schoolid"];?>'
	},function(){
		window.location.reload();
	})	
}
function delall()
{
	result = '';
	$('.ctl').each(function(i)
	{
		if($(this).attr('checked') == true)
		{
			if(result == '')
			{
				if($(this).attr('delid') != '')
				result = $(this).attr('delid');
			}else
			{
				if($(this).attr('delid') != '')
				result += ','+$(this).attr('delid');
			}
		}
	})
	
	$.post('__URL__/del_sch_spe',{
		'id':result,
	},function(){
		window.location.reload();
	})	
}

</script>
<style>
select{height:200px;}
select option{height:11px; line-height:11px; margin:0; padding:0; overflow:hidden; border:none;}
.top_class{background:#ddd; color:#333;}
</style>
</head>
<body>

<div class="spe_list">
<p>专业列表</p>
<table border="1">
<tr><td>&nbsp;</td><td>名称</td><td>是否本校专业</td><td>操作</td></tr>
<?php if(is_array($spe_arr)): $i = 0; $__LIST__ = $spe_arr;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): ++$i;$mod = ($i % 2 )?><tr class="top_class"><td colspan="4"><?php echo ($vo["title"]); ?></td></tr>
<?php if(!empty($vo["child"])): ?><?php if(is_array($vo["child"])): $i = 0; $__LIST__ = $vo["child"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo2): ++$i;$mod = ($i % 2 )?><tr><td><input type="checkbox" class="ctl" value="<?php echo ($vo2["id"]); ?>" delid="<?php echo ($vo2["sch_id"]); ?>" name="sel[]" /></td><td>--<?php echo ($vo2["title"]); ?></td>
<td><?php if(isset($vo2["in_sch"])): ?>是<?php else: ?>否<?php endif; ?></td>
<td><?php if(isset($vo2["in_sch"])): ?><input type="button" onclick="del('<?php echo ($vo2["sch_id"]); ?>')" value="删"/><input  type="button" onclick="edit('<?php echo ($vo2["sch_id"]); ?>')" value="改" /><?php else: ?><input type="button" value="加" onclick="add('<?php echo ($vo2["id"]); ?>')" /><?php endif; ?>
</td></tr><?php endforeach; endif; else: echo "" ;endif; ?><?php endif; ?><?php endforeach; endif; else: echo "" ;endif; ?>
</table>
<input type="button" onclick="checkall()" value="全选" /> <input type="button" onclick="addall()" value="全部添加" /> <input type="button" onclick="delall()" value="批量删除" />

</div>
</body>
</html>